package com.lyk.swap.orm;

import java.util.Date;

import com.lyk.swap.struts.action.BaseAction;

/**
 * Trade entity. @author MyEclipse Persistence Tools
 */

public class Trade implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 3407616073800759989L;
	private static final String BUY = "BUY";
	private static final String SELL = "SELL";
	protected Integer tradeid;
	protected Trader trader;
	protected Product product;
	protected String counterparty;
	protected Boolean buy;
	protected Integer quantity;
	protected Date start;
	protected Date end;
	protected Double price;
	protected String settlement;

	// Constructors

	/** default constructor */
	public Trade() {
	}

	/** full constructor */
	public Trade(Trader trader, Product product, String counterparty,
			Boolean buy, Integer quantity, Date start, Date end, Double price,
			String settlement) {
		this.trader = trader;
		this.product = product;
		this.counterparty = counterparty;
		this.buy = buy;
		this.quantity = quantity;
		this.start = start;
		this.end = end;
		this.price = price;
		this.settlement = settlement;
	}

	public Trade(Trade trade) {
		tradeid = trade.tradeid;
		trader = trade.trader;
		product = trade.product;
		counterparty = trade.counterparty;
		buy = trade.buy;
		quantity = trade.quantity;
		start = trade.start;
		end = trade.end;
		price = trade.price;
		settlement = trade.settlement;
	}

	// Property accessors

	public Integer getTradeid() {
		return tradeid;
	}

	public void setTradeid(Integer tradeid) {
		this.tradeid = tradeid;
	}

	public Trader getTrader() {
		return trader;
	}

	public void setTrader(Trader trader) {
		this.trader = trader;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public String getCounterparty() {
		return counterparty;
	}

	public void setCounterparty(String counterparty) {
		this.counterparty = counterparty;
	}

	public Boolean getBuy() {
		return buy;
	}

	public void setBuy(Boolean buy) {
		this.buy = buy;
	}

	public Integer getQuantity() {
		return quantity;
	}

	public void setQuantity(Integer quantity) {
		this.quantity = quantity;
	}

	public Date getStart() {
		return start;
	}

	public void setStart(Date start) {
		this.start = start;
	}

	public Date getEnd() {
		return end;
	}

	public void setEnd(Date end) {
		this.end = end;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public String getSettlement() {
		return settlement;
	}

	public void setSettlement(String settlement) {
		this.settlement = settlement;
	}

	public String getFormatBuy() {
		return buy ? BUY : SELL;
	}

	public String getFormatStart() {
		return BaseAction.format(start);
	}

	public String getFormatEnd() {
		return BaseAction.format(end);
	}

	public String getFormatPrice() {
		return BaseAction.format(price);
	}

	public String getFormatCode() {
		return product.getCode();
	}

}